package cn.itnanls.Controller;

import cn.itnanls.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.jms.Session;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author Ding
 */
@RequestMapping("/login/")
@Controller
public class LoginController {
    @RequestMapping("*")
    public String showUser(javax.servlet.http.HttpServletRequest request, HttpServletResponse response, HttpSession session, Model model, User user) throws Exception {
        if(user.getUsername().equals( "zhangsan" )&&user.getPassword().equals( "123" )){
            session.setAttribute( "username",user.getUsername() );
            model.addAttribute( "username",user.getUsername() );
            return "user";
        }
//        多一个/就不会自动拼接了
        return "redirect:/index.jsp";
    }

}
